/*======================================================================*\
|| #################################################################### ||
|| # vt.Lai balloonPopup 1.0                                          # ||
|| # ---------------------------------------------------------------- # ||
|| # Copyright ©2010-2013 Vu Thanh Lai. All Rights Reserved.          # ||
|| # Please do not remove this comment lines.                         # ||
|| # -------------------- LAST MODIFY INFORMATION ------------------- # ||
|| # Last Modify: 22-01-2013 12:10:00 PM by: Vu Thanh Lai             # ||
|| #################################################################### ||
\*======================================================================*/
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*\
|*-------Please specify source when using my code or a part of them-----*|
\*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

function balloonPopup(){
	this.playDuration=10; //In second
	this.innerWidth=250; //In pixel
	this.innerHeight=250; //In Pixel
	this.marginTop=-10; //In Pixel
	this.isDown=0;
	this.cookieName='closeBalloonPopup';
	this.closePopup=function(){
		var thisObj=this;
		if(this.isDown)
		{
			jQuery('#balloonPopupWrapper').fadeOut('fast',function(){
				jQuery(this).remove();
				document.cookie=thisObj.cookieName+'=1;path=/';
			});
			return true;
		}
		var h=jQuery(window).height();
		var curTop=jQuery(window).height()-jQuery('#balloonPopupWrapper').height();
		jQuery('#balloonPopupWrapper').css('top',curTop+'px');
		jQuery('#balloonPopupWrapper').css('bottom','auto');
		jQuery('#balloonPopupWrapper').animate({'top':h},'fast',function(){
			jQuery(this).remove();
			document.cookie=thisObj.cookieName+'=1;path=/';
		});
	}
	this.downPopup=function(){
		if(this.isDown)
			return false;
		var thisObj=this;
		var newTop=jQuery(window).height()-38;
		var curTop=jQuery(window).height()-jQuery('#balloonPopupWrapper').height();
		jQuery('#balloonPopupWrapper').css('top',curTop+'px');
		jQuery('#balloonPopupWrapper').css('bottom','auto');
		jQuery('#balloonPopupWrapper').animate({'top':newTop},'fast',function(){
			jQuery('#balloonPopupHead').fadeIn('fast');
			jQuery('#balloonControl').fadeOut('fast');
			thisObj.isDown=1;
		});			
		setTimeout('restoreAds()',60000);
	}
	this.restorePopup=function(){
		var thisObj=this;
		jQuery('#balloonPopupHead').fadeOut('fast',function(){
			var newTop=jQuery(window).height()-jQuery('#balloonPopupWrapper').height();
			jQuery('#balloonPopupWrapper').animate({'top':newTop},'fast',function(){
				jQuery('#balloonControl').fadeIn('fast');
				thisObj.isDown=0;
			});
		});		
		setTimeout('closeBalloonPopup()',10000);
	}
	this.showPopup=function(){
		if(document.cookie.indexOf(this.cookieName)!=-1)
			return false;
		var thisObj=this;
		if(jQuery('#vtlaiBalloonPopup').length==0)
		{
			jQuery('body').append('<div id="balloonPopupWrapper" style="position: fixed; left: 0px;bottom: 0px; border: 1px solid #4B4F55;">\
				<h4 id="balloonPopupHead" style="-webkit-box-sizing: border-box;-webkit-margin-before: 0;-webkit-margin-after: 0;-webkit-margin-start: 0;-webkit-margin-end: 0;-webkit-padding-start: 0;-webkit-padding-end: 0;padding:10px;margin:0;color: white;display: none;background-color: #4B4F55;font-size: 14px;font-family: Arial,Tahoma,San-serif;"><span class="restoreBalloonPopup" style="cursor: pointer;">Quảng cáo trên YourITV.NET</span><a class="closeBalloonPopup" style="color: #FFF;text-decoration: none;float:right;margin:0;">X</a><a class="restoreBalloonPopup" style="color: #FFF;text-decoration: none;float:right;margin:0;margin-right: 10px;margin-top: -2px;">↑</a></h4>\
				<div style="display: block;background-color:#FFF;width:'+this.innerWidth+'px;height:'+this.innerHeight+'px;">\
					<div id="balloonControl" style="position: absolute;right: 0px;top:0px;"><a id="pushDownBalloonPopup" style="cursor: pointer;background:url(http://vipvnsource.googlecode.com/svn/img/www.youritv.net-balloonpopup.png) -8px -4px no-repeat;width: 30px;height: 30px; display: inline-block;"></a><a id="closeBalloonPopup" style="cursor: pointer;background:url(http://vipvnsource.googlecode.com/svn/img/www.youritv.net-balloonpopup.png) -10px -73px no-repeat;width: 30px;height: 30px; display: inline-block;"></a></div>\
					<a href="http://www.vipvn.org/p/redirect.html?url=http://shop.vipvn.org/index.php?lang=vi&name=banners&op=click&id=13" rel="nofollow" alt="Gửi tin nhắn miễn phí" title="Gửi tin nhắn miễn phí"><img src="http://vipvnsource.googlecode.com/svn/img/www.vipvn.org-sms-ads.png" height="250" width="300" border="0" alt="Gửi tin nhắn miễn phí" title="Gửi tin nhắn miễn phí"/></a>\
				</div>\
			</div>');
			jQuery('.closeBalloonPopup,#closeBalloonPopup').click(function(){
				thisObj.closePopup();
			});
			jQuery('#pushDownBalloonPopup').click(function(){
				thisObj.downPopup();
			});
			jQuery('.restoreBalloonPopup').click(function(){
				thisObj.restorePopup();
			});
		}
		setTimeout('closeBalloonPopup()',10000);
	}
};
var vtlaiBalloon=new balloonPopup();
function closeBalloonPopup()
{
	vtlaiBalloon.downPopup();
}
function restoreAds()
{
	vtlaiBalloon.restorePopup();
}
jQuery(document).ready(function(){
	vtlaiBalloon.showPopup();
});
